
import java.io.File;

import org.artofsolving.jodconverter.OfficeDocumentConverter;
import org.artofsolving.jodconverter.office.DefaultOfficeManagerConfiguration;
import org.artofsolving.jodconverter.office.OfficeManager;

/**
 * Created by Carey on 15-2-2.
 */
public class Word2Pdf {

	static String OpenOffice_HOME;// 这里是OpenOffice的安装目录,
									// 在我的项目中,为了便于拓展接口,没有直接写成这个样子,但是这样是绝对没问题的
	
	public Word2Pdf(String OpenOffice_HOME, String pdf2swf) {
		this.OpenOffice_HOME = OpenOffice_HOME;

	}

	public static void main(String args[]) {
		try { 
			office2PDF("c:\\java曹丽丽.docx", "c:\\555.pdf");

//			office2PDF("c:\\cv\\李勇.doc", "c:\\444.pdf");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	// soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;"
	// -nofirststartwizar
	public static void office2PDF(String sourceFile, String destFile) {

		OfficeManager officeManager = new DefaultOfficeManagerConfiguration() //
				.setOfficeHome("D:/OpenOffice4") // 配置openoffice路径
				.buildOfficeManager(); //
		officeManager.start();
		// 连接OpenOffice
		OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager);
		converter.convert(new File(sourceFile), new File(destFile));
		officeManager.stop();

	}

}
